<?php
require('config.php');
		$text=$_REQUEST['text'];
		$shop_id=$_REQUEST['shop_id'];
		$sql="select * from `".$oto."_goods` where shopId='{$shop_id}' and goodsName LIKE '%$text%' and isSale=1 and goodsStatus=1 and goodsFlag=1";
		$result=$db->query($sql);
		//file_put_contents("tsxx.txt", "\r\n".$sql."\r\n", FILE_APPEND);
		while($row=$result->fetch_assoc()){
			$goods_list[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($goods_list))
		{
			$time_star=time();
			$time_end=$time_star-3600*24*30;
			$time_star1=date('Y-m-d H:i:s',$time_end);
			$time_end1=date('Y-m-d H:i:s',$time_star);
			for($i=0;$i<count($goods_list);$i++)
			{
				$goods_list[$i]['goodsDesc']="";
				$goods_id=$goods_list[$i]['goodsId'];
				$sql2="select * from `".$oto."_goods_attributes`,`".$oto."_attributes` where ".$oto."_goods_attributes.goodsId='$goods_id' and isPriceAttr=1 and ".$oto."_goods_attributes.attrId=".$oto."_attributes.attrId order by ".$oto."_attributes.attrId ASC";
				$result=$db->query($sql2);
				//file_put_contents("tsxx.txt", "\r\n".$goods_list[$i]['goodsName'].":".$sql2."\r\n", FILE_APPEND);
				while($row=$result->fetch_assoc()){
					$shuxing_info[$i]=$row;//将取得的所有数据赋值给person_info数组
				}
				if(!isset($shuxing_info[$i]))
				{
					$goods_list[$i]['is_shuxing']=0;
				}
				else
				{
					$goods_list[$i]['is_shuxing']=1;
				}
				$sql="select * from `".$oto."_orders`,`".$oto."_order_goods` where ".$oto."_orders.orderId=".$oto."_order_goods.orderId and ".$oto."_order_goods.goodsId='{$goods_id}' and createTime>='$time_star1' and createTime<='$time_end1' and orderStatus='4'";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$order_list[$i][]=$row;//将取得的所有数据赋值给person_info数组
				}
				$sum=0;
				if(isset($order_list[$i]))
				{
					for($j=0;$j<count($order_list[$i]);$j++)
					{
						$sum+=$order_list[$i][$j]['goodsNums'];
					}
				}
				$goods_list[$i]['yue_xiaoliang']=$sum;
				//file_put_contents("tsxx.txt", "\r\n"."是否有属性:".$goods_list[$i]['is_shuxing']."\r\n", FILE_APPEND);
			}
		}
		if(isset($goods_list)) echo json_encode($goods_list);
		else echo '[]';
?>